function changecity(select) {


	if (select.id === 's_province') {
		{
			country = '';
			city = '';
			province = '';
			province = $('#s_province').find("option:selected").text();
			address = province;
			level=10;
		}
		provincecode = $('#s_province').val();
	
	} else {
		if (select.id === 's_city') {

			{
				country = '';
				city = '';
				city = $('#s_city').find("option:selected").text();

				address = province + city;
				level=14;
			}
			citycode = $('#s_city').val();
		
		} else {
			if (select.id === 's_county') {

				{
					country = '';
					country = $('#s_county').find("option:selected").text();
					address = province + city + country;
					level=16;
					countrycode = $('#s_county').val();
				}

			}
		}
	}
}

function addmarkerf(point) {
	
	if (marker != null) {
		map.clearOverlays();
		marker = null;
	}
	marker = new BMap.Marker(point); // 创建标注
	map.addOverlay(marker);
	marker.enableDragging();
	marker.addEventListener("dragend", function(e) {
		getGeoAddress(new BMap.Point(e.point.lng, e.point.lat));
	});
	getGeoAddress(point);
}

function darwplacewithword() {
	$placewithword.empty();
	for (x in list) {
		if (list[x].isdel != true)
			$placewithword.append('<li >' + list[x].address
					+ list[x].detailAddress + '<a  onclick="updateplace(' + x
					+ ')" class="am-inline">修改</a><a onclick="deleteplace(' + x
					+ ')" class="am-inline">删除</a></li>');
	}
}

function deleteplace(item) {
	places = places - 1;
	list[item].isdel = true;
	darwplacewithword();
}

function updateplace(item) {
	list[item].isdel = true;
	lat = list[item].lat;
	lng = list[item].lng;
	address = list[item].address;
	countrycode = list[item].countrycode;
	detailAddress = list[item].detailAddress;
	countrycode = list[item].countrycode;

	$modal.modal('toggle');
	drawmap();
	setPlace(detailAddress) ;
	$('#detailaddress').val(detailAddress);
	marker = new BMap.Marker(new BMap.Point(lng, lat)); // 创建标注
	map.addOverlay(marker);
}
var opts = {
	width : 250, // 信息窗口宽度
	height : 100, // 信息窗口高度
	title : "地址" // 信息窗口标题
}

function getGeoAddress(point) {
	myGeo.getLocation(point,
			function(result) {
				if (result) {
					geoaddress = result.address;
					lat = point.lat;
					lng = point.lng;
					infoWindow = new BMap.InfoWindow(geoaddress, opts); // 创建信息窗口对象
					map.openInfoWindow(infoWindow,point);
				}
			});

}
function drawmap(button) {
 province=$('#s_province').find("option:selected").text();
	city=$('#s_city').find("option:selected").text();
	country=$('#s_county').find("option:selected").text();
	countrycode=$('#s_county').find("option:selected").val();
	citycode=$('#s_city').find("option:selected").val();
	provincecode=$('#s_county').find("option:selected").val();

	map.centerAndZoom(address, level);
	map.addControl(new BMap.NavigationControl());
	map.addControl(new BMap.ScaleControl());
	map.addControl(new BMap.OverviewMapControl());
	map.addControl(new BMap.MapTypeControl());

/*	var size = new BMap.Size(3, 3);
	map.addControl(new BMap.CityListControl({
	    anchor: BMAP_ANCHOR_TOP_LEFT,
	    offset: size,
	    // 切换城市之间事件
	    // onChangeBefore: function(){
	    //    alert('before');
	    // },
	    // 切换城市之后事件
	    // onChangeAfter:function(){
	    //   alert('after');
	    // }
	}));*/
/*map.centerAndZoom(address, level);
	map.addControl(new BMap.NavigationControl());
	map.addControl(new BMap.ScaleControl());
	map.addControl(new BMap.OverviewMapControl());
	map.addControl(new BMap.MapTypeControl());*/
//	getBoundary();
	if (marker != null) {
		map.clearOverlays();
		marker = null;
		infoWindow = null;
	}
}

function getBoundary()
{ 
var bdary = new BMap.Boundary();
bdary.get(address, function(rs){ //获取行政区域
map.clearOverlays(); //清除地图覆盖物 
var count = rs.boundaries.length; //行政区域的点有多少个

for(var i = 0; i < count; i++){
var ply = new BMap.Polygon(rs.boundaries[i], {strokeWeight: 2, strokeColor: "#ff0000"}); //建立多边形覆盖物
map.addOverlay(ply); //添加覆盖物
map.setViewport(ply.getPath()); //调整视野 
} 

}); 
}
Date.prototype.Format = function(fmt) { // author: meizz
	var o = {
		"M+" : this.getMonth() + 1, // 月份
		"d+" : this.getDate(), // 日
		"h+" : this.getHours(), // 小时
		"m+" : this.getMinutes(), // 分
		"s+" : this.getSeconds(), // 秒
		"q+" : Math.floor((this.getMonth() + 3) / 3), // 季度
		"S" : this.getMilliseconds()
	// 毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	for ( var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
					: (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}